package com.yy.train.ticket.train.controller;

import java.util.Arrays;
import java.util.Map;

import com.yy.train.ticket.into.TtLine;
import com.yy.train.ticket.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yy.train.ticket.train.entity.TtLineLinkSectionEntity;
import com.yy.train.ticket.train.service.TtLineLinkSectionService;




/**
 * 线路链的路段
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-10-18 17:53:49
 */
@RestController
@RequestMapping("tt/linksection")
public class TtLineLinkSectionController {
    @Autowired
    private TtLineLinkSectionService ttLineLinkSectionService;

    /**
     * 列表
     */
    @PostMapping("/ratio")
    public R ratio(@RequestBody TtLine line){
        return ttLineLinkSectionService.ratio(line);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{linkSectionId}")
    public R info(@PathVariable("linkSectionId") Long linkSectionId){
		TtLineLinkSectionEntity ttLineLinkSection = ttLineLinkSectionService.getById(linkSectionId);
        return R.ok().put("ttLineLinkSection", ttLineLinkSection);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TtLineLinkSectionEntity ttLineLinkSection){
		ttLineLinkSectionService.save(ttLineLinkSection);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TtLineLinkSectionEntity ttLineLinkSection){
		ttLineLinkSectionService.updateById(ttLineLinkSection);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] linkSectionIds){
		ttLineLinkSectionService.removeByIds(Arrays.asList(linkSectionIds));

        return R.ok();
    }

}
